
_realname=byacc
pkgname=btyacc
pkgver=20210109
pkgrel=1
pkgdesc="btyacc - an LALR(1) parser generator with support for backtracking"
arch=('i686' 'x86_64')
url="https://invisible-island.net/byacc"
license=('Public Domain')
groups=('base-devel')

source=(${_realname}-${pkgver}.tar.gz::https://github.com/ThomasDickey/byacc-snapshots/archive/t${pkgver}.tar.gz)
sha256sums=('7cd3218438766c41dfb487b844e9ae213158c51934efd1b2746f33129e2ed5dc')


prepare() {
  cd ${_realname}-snapshots-t${pkgver}
  autoreconf -vfi
}

build() {
  cd ${_realname}-snapshots-t${pkgver}
  mkdir -p build-${MSYSTEM_CHOST}
  pushd build-${MSYSTEM_CHOST}
  ../configure -C \
    --enable-btyacc \
    --program-prefix=bt \
    --with-max-table-size=18000 \
    --program-transform-name='s,\^,bt,'
  make
}

check() {
  cd ${_realname}-snapshots-t${pkgver}/build-${MSYSTEM_CHOST}
  make check
}

package() {
  cd ${_realname}-snapshots-t${pkgver}
  mkdir -p "${pkgdir}/usr/share/licenses/${pkgname}"
  cp -pv package/debian/copyright "${pkgdir}/usr/share/licenses/${pkgname}"
  cd build-${MSYSTEM_CHOST}
  make DESTDIR=${pkgdir} install
}
